package com.example.canteen.controller;
import com.example.canteen.domain.Inventory;
import com.example.canteen.domain.Products;
import com.example.canteen.service.InventoryService;
import com.example.canteen.service.ProductsService;
import com.example.canteen.util.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController

@RequestMapping("/inventory")
@Api(tags = "餐厅库存管理(0304 高凯)")
//@Anonymous
public class InventoryController {
    @Autowired
    InventoryService service;
    @GetMapping("/getInventoryListAll")
    @ApiOperation(value = "获取所有库存列表")
    public AjaxResult getInventoryListAll() {
        System.out.println(service.selectAllInventory());
        return AjaxResult.success(service.selectAllInventory());
    };
    @GetMapping("/getInventoryById")
    @ApiOperation(value = "根据id查询库存商品信息")
    public AjaxResult getInventoryById(int id) {
        System.out.println(service.selectInventoryById(id));
        return AjaxResult.success(service.selectInventoryById(id));
    }
    @PostMapping("/insertInventory")
    @ApiOperation(value = "增加库存")
    public AjaxResult addInventory(@RequestBody Inventory inventory) {
        return AjaxResult.success(service.insertInventory(inventory));
    }
//    @PutMapping("/UpdateInventory")
//    @ApiOperation(value = "修改库存数量")
//    public AjaxResult UpdateInventory(@RequestBody Inventory inventory){
//        return AjaxResult.success(service.updateInventory(inventory));
//    }
    @DeleteMapping("/DeleteInventory")
    @ApiOperation(value = "删除库存信息")
    public AjaxResult DeleteInventory(int id) {
        return AjaxResult.success(service.deleteInventoryByID(id));
    }
}
